
<!doctype html>
<html lang="zh" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
        <meta name="description" content="晒太阳的松鼠的博客">
      
      
        <meta name="author" content="songshu007">
      
      
        <link rel="canonical" href="https://github.com/songshu007/C%2B%2B/Direct2D/Direct2D%E5%85%A8%E5%B1%8F/Direct2D%E5%85%A8%E5%B1%8F/">
      
      <link rel="icon" href="../../../../images/favicon.png">
      <meta name="generator" content="mkdocs-1.3.1, mkdocs-material-8.3.9">
    
    
      
        <title>Direct2d 不能全屏？ - 晒太阳的松鼠的博客</title>
      
    
    
      <link rel="stylesheet" href="../../../../assets/stylesheets/main.1d29e8d0.min.css">
      
        
        <link rel="stylesheet" href="../../../../assets/stylesheets/palette.cbb835fc.min.css">
        
      
      
    
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
    <script>__md_scope=new URL("../../../..",location),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
  </head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="orange">
  
    
    
      <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#direct2d" class="md-skip">
          跳转至
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

<header class="md-header" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="页眉">
    <a href="../../../.." title="晒太阳的松鼠的博客" class="md-header__button md-logo" aria-label="晒太阳的松鼠的博客" data-md-component="logo">
      
  <img src="../../../../images/logo.png" alt="logo">

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            晒太阳的松鼠的博客
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              Direct2d 不能全屏？
            
          </span>
        </div>
      </div>
    </div>
    
      <form class="md-header__option" data-md-component="palette">
        
          
          
          <input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="orange"  aria-label="切换至夜间模式"  type="radio" name="__palette" id="__palette_1">
          
            <label class="md-header__button md-icon" title="切换至夜间模式" for="__palette_2" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3 3.19.09m3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95 2.06.05m-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31Z"/></svg>
            </label>
          
        
          
          
          <input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="indigo" data-md-color-accent="orange"  aria-label="切换至日间模式"  type="radio" name="__palette" id="__palette_2">
          
            <label class="md-header__button md-icon" title="切换至日间模式" for="__palette_1" hidden>
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5c-.84 0-1.65.15-2.39.42L12 2M3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29L3.34 7m.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14L3.36 17M20.65 7l-1.77 3.79a7.023 7.023 0 0 0-2.38-4.15l4.15.36m-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29L20.64 17M12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44L12 22Z"/></svg>
            </label>
          
        
      </form>
    
    
    
      <label class="md-header__button md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="查找">
        
        <button type="reset" class="md-search__icon md-icon" aria-label="清空当前内容" tabindex="-1">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
        </button>
      </nav>
      
        <div class="md-search__suggest" data-md-component="search-suggest"></div>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            正在初始化搜索引擎
          </div>
          <ol class="md-search-result__list"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
      <div class="md-header__source">
        <a href="https://github.com/songshu007" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
  </div>
  <div class="md-source__repository">
    SongShu007
  </div>
</a>
      </div>
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
            
<nav class="md-tabs" aria-label="标签" data-md-component="tabs">
  <div class="md-tabs__inner md-grid">
    <ul class="md-tabs__list">
      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../STM32/2024-2-19-22-47/WS2812/" class="md-tabs__link">
        STM32
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../Linux/2022-7-31-3-32/Linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="md-tabs__link">
        Linux
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../English/" class="md-tabs__link">
        English
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../Win32/2022-6-24/Win32-22-6-24/" class="md-tabs__link">
        Win32
      </a>
    </li>
  

      
        
  
  
    
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../2022-7-7-9-40/Direct2dInit/" class="md-tabs__link md-tabs__link--active">
        Direct2D
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../QT/2022-7-26-10-00/QT%E7%BC%96%E8%AF%91%E6%8A%A5%E9%94%99/" class="md-tabs__link">
        QT
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../wxWidgets/wxWidgets%E9%85%8D%E7%BD%AE/wxWidgets%E9%85%8D%E7%BD%AE/" class="md-tabs__link">
        wxWidgets
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-7-7-9-52/%E5%BC%BA%E5%88%B6%E8%BD%AC%E6%8D%A2%E8%BF%90%E7%AE%97%E7%AC%A6/" class="md-tabs__link">
        杂项
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../%E5%8D%95%E7%89%87%E6%9C%BA/SPIFFS/" class="md-tabs__link">
        单片机
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../OpenGL/%E6%A6%82%E8%BF%B0/" class="md-tabs__link">
        OpenGL
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../../../%E5%A4%A7%E6%95%B0%E6%8D%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" class="md-tabs__link">
        大数据
      </a>
    </li>
  

      
    </ul>
  </div>
</nav>
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

  


<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="导航栏" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../../../.." title="晒太阳的松鼠的博客" class="md-nav__button md-logo" aria-label="晒太阳的松鼠的博客" data-md-component="logo">
      
  <img src="../../../../images/logo.png" alt="logo">

    </a>
    晒太阳的松鼠的博客
  </label>
  
    <div class="md-nav__source">
      <a href="https://github.com/songshu007" title="前往仓库" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
  </div>
  <div class="md-source__repository">
    SongShu007
  </div>
</a>
    </div>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_1" type="checkbox" id="__nav_1" checked>
      
      
      
        
          
        
      
      
        <label class="md-nav__link" for="__nav_1">
          STM32
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="STM32" data-md-level="1">
        <label class="md-nav__title" for="__nav_1">
          <span class="md-nav__icon md-icon"></span>
          STM32
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../STM32/2024-2-19-22-47/WS2812/" class="md-nav__link">
        Arduino WS2812库的 EVERY_N_MILLISECONDS 宏定义
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_2" type="checkbox" id="__nav_2" checked>
      
      
      
        
          
        
          
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_2">
          Linux
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="Linux" data-md-level="1">
        <label class="md-nav__title" for="__nav_2">
          <span class="md-nav__icon md-icon"></span>
          Linux
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../Linux/2022-7-31-3-32/Linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" class="md-nav__link">
        Linux 常用命令
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../Linux/2022-8-2-3-48/Nginx/" class="md-nav__link">
        Nginx 的笔记
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../Linux/2022-8-2-4-05/SCP%20%E5%91%BD%E4%BB%A4%E4%B8%8A%E4%BC%A0%E8%87%B3%E8%BF%9C%E7%A8%8B%E6%9C%8D%E5%8A%A1%E5%99%A8/" class="md-nav__link">
        SCP 上传命令
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../Linux/2022-8-10-1-16/Linux%E9%85%8D%E7%BD%AEC%23%E7%8E%AF%E5%A2%83/" class="md-nav__link">
        Linux 配置 C# 环境
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_3" type="checkbox" id="__nav_3" checked>
      
      
      
        
          
            
          
        
      
      
        
        
        <div class="md-nav__link md-nav__link--index ">
          <a href="../../../../English/">English</a>
          
        </div>
      
      <nav class="md-nav" aria-label="English" data-md-level="1">
        <label class="md-nav__title" for="__nav_3">
          <span class="md-nav__icon md-icon"></span>
          English
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_4" type="checkbox" id="__nav_4" checked>
      
      
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_4">
          Win32
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="Win32" data-md-level="1">
        <label class="md-nav__title" for="__nav_4">
          <span class="md-nav__icon md-icon"></span>
          Win32
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-6-24/Win32-22-6-24/" class="md-nav__link">
        Win32 字符编码
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-6-27/Win32-22-6-27/" class="md-nav__link">
        Win32 最小代码和一些常用消息解释
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-6-30-4-33/Win32-%E5%A4%9A%E7%BA%BF%E7%A8%8B/" class="md-nav__link">
        Win32 多线程 - 01（创建和管理线程）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-6-30-6-00/Win32-%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%90%8C%E6%AD%A5/" class="md-nav__link">
        Win32 多线程同步 - 02（原子锁）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-7-1-1-00/Win32-%E4%BA%92%E6%96%A5%E9%94%81/" class="md-nav__link">
        Win32 多线程同步 - 03（互斥锁）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-7-1-4-20/Win32-%E4%BA%8B%E4%BB%B6/" class="md-nav__link">
        Win32 多线程同步 - 04（事件）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-7-3-11-22/%E6%8E%A7%E5%88%B6%E5%8F%B0%E5%8F%8C%E7%BC%93%E5%86%B2/" class="md-nav__link">
        Win32 控制台双缓冲
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-7-1-10-00/%E9%9D%99%E6%80%81%E5%BA%93/" class="md-nav__link">
        静态库
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../Win32/2022-7-2-2-00/%E5%8A%A8%E6%80%81%E5%BA%93/" class="md-nav__link">
        动态库
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
    
  
  
    
    <li class="md-nav__item md-nav__item--active md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle" data-md-toggle="__nav_5" type="checkbox" id="__nav_5" checked>
      
      
      
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_5">
          Direct2D
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="Direct2D" data-md-level="1">
        <label class="md-nav__title" for="__nav_5">
          <span class="md-nav__icon md-icon"></span>
          Direct2D
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../2022-7-7-9-40/Direct2dInit/" class="md-nav__link">
        Direct2d 初始化
      </a>
    </li>
  

            
          
            
              
  
  
    
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          Direct2d 不能全屏？
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        Direct2d 不能全屏？
      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#2023-1-2" class="md-nav__link">
    2023-1-2
  </a>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_6" type="checkbox" id="__nav_6" checked>
      
      
      
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_6">
          QT
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="QT" data-md-level="1">
        <label class="md-nav__title" for="__nav_6">
          <span class="md-nav__icon md-icon"></span>
          QT
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../QT/2022-7-26-10-00/QT%E7%BC%96%E8%AF%91%E6%8A%A5%E9%94%99/" class="md-nav__link">
        QT因库版本不一致导致的报错
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../QT/2022-7-30-1-30/QT%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E5%8F%91%E5%B8%83/" class="md-nav__link">
        QT应用程序发布
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_7" type="checkbox" id="__nav_7" checked>
      
      
      
        
          
        
      
      
        <label class="md-nav__link" for="__nav_7">
          wxWidgets
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="wxWidgets" data-md-level="1">
        <label class="md-nav__title" for="__nav_7">
          <span class="md-nav__icon md-icon"></span>
          wxWidgets
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../wxWidgets/wxWidgets%E9%85%8D%E7%BD%AE/wxWidgets%E9%85%8D%E7%BD%AE/" class="md-nav__link">
        wxWidgets配置环境
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_8" type="checkbox" id="__nav_8" checked>
      
      
      
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
            
          
        
      
      
        
        
        <div class="md-nav__link md-nav__link--index ">
          <a href="../../../../%E6%9D%82%E9%A1%B9/C%E4%B8%AD%E7%9A%84%E8%BF%9E%E5%AD%97%E7%AC%A6/">杂项</a>
          
            <label for="__nav_8">
              <span class="md-nav__icon md-icon"></span>
            </label>
          
        </div>
      
      <nav class="md-nav" aria-label="杂项" data-md-level="1">
        <label class="md-nav__title" for="__nav_8">
          <span class="md-nav__icon md-icon"></span>
          杂项
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-7-7-9-52/%E5%BC%BA%E5%88%B6%E8%BD%AC%E6%8D%A2%E8%BF%90%E7%AE%97%E7%AC%A6/" class="md-nav__link">
        强制转换运算符
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-7-7-11-36/Visual%20Studio%E5%B0%8F%E6%8A%80%E5%B7%A7/" class="md-nav__link">
        Visual Studio 小技巧
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-7-31-3-26/Win10_SSH%E8%BF%9E%E6%8E%A5%E6%9C%8D%E5%8A%A1%E5%99%A8/" class="md-nav__link">
        通过 SSH 命令连接云服务器
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-8-3-2-54/VsCode%E4%BD%BF%E7%94%A8%E7%AC%94%E8%AE%B0/" class="md-nav__link">
        VsCode 使用笔记
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2022-8-9-7-22/NSIS%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97/" class="md-nav__link">
        NSIS 使用指南
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0/%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0/" class="md-nav__link">
        回调函数
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/2048%E6%80%9D%E8%B7%AF/2048%E6%80%9D%E8%B7%AF/" class="md-nav__link">
        2048 游戏合并算法思路
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E6%9D%82%E9%A1%B9/%E9%A3%8E%E5%8F%B6%E7%A9%BF%E8%A1%8C%E6%80%9D%E8%B7%AF/%E9%A3%8E%E5%8F%B6%E7%A9%BF%E8%A1%8C%E6%80%9D%E8%B7%AF/" class="md-nav__link">
        风叶穿行思路
      </a>
    </li>
  

            
          
            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_9" type="checkbox" id="__nav_9" checked>
      
      
      
        
          
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_9">
          单片机
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="单片机" data-md-level="1">
        <label class="md-nav__title" for="__nav_9">
          <span class="md-nav__icon md-icon"></span>
          单片机
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E5%8D%95%E7%89%87%E6%9C%BA/SPIFFS/" class="md-nav__link">
        SPIFFS文件系统
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E5%8D%95%E7%89%87%E6%9C%BA/ESP_12f_Deepsleed/ESP_12f_Deepsleed/" class="md-nav__link">
        如何让 ESP_12F 在待机状态下只消耗 3钠安
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../%E5%8D%95%E7%89%87%E6%9C%BA/ESP%E5%BC%82%E5%B8%B8%E5%A4%8D%E4%BD%8D/ESP%E6%88%96Arduino%E5%BC%82%E5%B8%B8%E5%A4%8D%E4%BD%8D/" class="md-nav__link">
        ESP或Arduino异常复位
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_10" type="checkbox" id="__nav_10" checked>
      
      
      
        
          
        
          
        
          
        
          
        
          
        
      
      
        <label class="md-nav__link" for="__nav_10">
          OpenGL
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" aria-label="OpenGL" data-md-level="1">
        <label class="md-nav__title" for="__nav_10">
          <span class="md-nav__icon md-icon"></span>
          OpenGL
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../OpenGL/%E6%A6%82%E8%BF%B0/" class="md-nav__link">
        概述
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../OpenGL/001-%E9%A1%B9%E7%9B%AE%E8%AE%BE%E7%BD%AE/" class="md-nav__link">
        001-项目设置
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../OpenGL/002-%E5%85%A5%E5%8F%A3%E7%82%B9%E5%92%8CApplication%E7%B1%BB/" class="md-nav__link">
        002-入口点和Application类
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../OpenGL/003-%E6%97%A5%E5%BF%97%E7%B3%BB%E7%BB%9F/" class="md-nav__link">
        003-日志系统
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../../OpenGL/004-Premake/" class="md-nav__link">
        004-Premake
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
        <input class="md-nav__toggle md-toggle md-toggle--indeterminate" data-md-toggle="__nav_11" type="checkbox" id="__nav_11" checked>
      
      
      
        
          
            
          
        
      
      
        
        
        <div class="md-nav__link md-nav__link--index ">
          <a href="../../../../%E5%A4%A7%E6%95%B0%E6%8D%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/">大数据</a>
          
        </div>
      
      <nav class="md-nav" aria-label="大数据" data-md-level="1">
        <label class="md-nav__title" for="__nav_11">
          <span class="md-nav__icon md-icon"></span>
          大数据
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
          
        </ul>
      </nav>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#2023-1-2" class="md-nav__link">
    2023-1-2
  </a>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          <div class="md-content" data-md-component="content">
            <article class="md-content__inner md-typeset">
              
                
  <a href="https://github.com/songshu007/C++/Direct2D/Direct2D全屏/Direct2D全屏.md" title="编辑此页" class="md-content__button md-icon">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25Z"/></svg>
  </a>



<h1 id="direct2d">Direct2D 全屏的问题</h1>
<h2 id="2023-1-2">2023-1-2</h2>
<p>Direct2d的全屏是真难搞，之前尝试在<code>CreateSwapChainForHwnd</code>函数里传全屏参数，但是发现怎么也不行，经过一系列调试之后，我发现了<code>IDXGISwapChain1</code>类有一个<code>SetFullscreenState</code>的函数可以切换全屏和窗口模式，于是我写了一个最小Demo，放在这里免得丢掉：</p>
<pre><code class="language-c++">#include &lt;Windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;wrl/client.h&gt;
#include &lt;dwrite.h&gt;
#include &lt;dxgi1_2.h&gt;
#include &lt;d2d1.h&gt;
#include &lt;d2d1_1.h&gt;
#include &lt;d3d11.h&gt;
#include &lt;dxgi1_2.h&gt;
#include &lt;d2d1_1helper.h&gt;
#include &lt;wincodec.h&gt;
#include &lt;iostream&gt;
#include &lt;chrono&gt;
#include &lt;string&gt;
#include &lt;thread&gt;
#include &lt;mutex&gt;
#include &lt;d2d1effects_2.h&gt;

#pragma comment(lib, &quot;d2d1.lib&quot;)
#pragma comment(lib, &quot;D3D11.lib&quot;)
#pragma comment(lib, &quot;Dwrite.lib&quot;)
#pragma comment(lib, &quot;Winmm.lib&quot;)
#pragma comment(lib, &quot;dxguid.lib&quot;)

#define CLASS_NAME L&quot;Test&quot;
#define WIND_NAME L&quot;Direct2d&quot;

HWND hwnd = NULL;
D2D1_POINT_2F m_MousePos = D2D1::Point2F(0.0f, 0.0f);
D2D1_POINT_2F m_WinSize = D2D1::Point2F(0.0f, 0.0f);

ID2D1SolidColorBrush* m_RedBrush = NULL;
ID2D1SolidColorBrush* m_BlackBrush = NULL;

ID2D1Factory1* m_d2dFactory = NULL;
ID2D1Device* m_d2dDevice = NULL;
ID2D1DeviceContext* m_d2dDeviceContext = NULL; 
ID3D11Device* m_d3dDevice = NULL;
ID3D11DeviceContext* m_d3dDeviceContext = NULL;
IDXGIDevice1* m_dxgiDevice = NULL;
IDXGIFactory2* m_dxgiFactory = NULL;
IDXGISwapChain1* m_dxgiSwapChain = NULL;
IDXGISurface1* m_dxgiSurface = NULL;
ID2D1Bitmap1* m_d2dTarget = NULL;

LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL InitDirect2d(HWND hwnd);
BOOL CreateRenderTarget();

bool Full = true;

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {

    WNDCLASSEXW wic;
    memset(&amp;wic, 0, sizeof(wic));
    wic.cbSize = sizeof(WNDCLASSEX);
    wic.hCursor = LoadCursor(0, IDC_ARROW);
    wic.hInstance = hInstance;
    wic.lpszClassName = CLASS_NAME;
    wic.lpfnWndProc = (WNDPROC)WindowProc;
    wic.style = CS_HREDRAW | CS_VREDRAW;

    if (!RegisterClassEx((WNDCLASSEXW*)&amp;wic))
        return NULL;

    RECT rect;
    rect.right = 800;
    rect.bottom = 600;
    rect.left = 0;
    rect.top = 0;
    AdjustWindowRect(&amp;rect, WS_OVERLAPPEDWINDOW, FALSE);

    hwnd = CreateWindowEx(0, CLASS_NAME, WIND_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hInstance, NULL);

    if (!InitDirect2d(hwnd)) return false;

    ShowWindow(hwnd, SW_SHOW);
    UpdateWindow(hwnd);

    m_dxgiSwapChain-&gt;SetFullscreenState(Full, NULL);
    m_d2dDeviceContext-&gt;CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black, 0.1f), &amp;m_BlackBrush);
    m_d2dDeviceContext-&gt;CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Red, 1.0f), &amp;m_RedBrush);

    MSG msg = { 0 };
    for (;;)
    {
        if (PeekMessageW(&amp;msg, NULL, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT) break;
            TranslateMessage(&amp;msg);
            DispatchMessageW(&amp;msg);
        }
        else
        {
            m_d2dDeviceContext-&gt;BeginDraw();

            m_d2dDeviceContext-&gt;FillRectangle(D2D1::RectF(0.0f, 0.0f, m_WinSize.x, m_WinSize.y), m_BlackBrush);

            m_d2dDeviceContext-&gt;FillEllipse(D2D1::Ellipse(m_MousePos, 50.0f, 50.0f), m_RedBrush);

            m_d2dDeviceContext-&gt;EndDraw();
            m_dxgiSwapChain-&gt;Present(1, 0);
        }
    }


};

BOOL InitDirect2d(HWND hwnd)
{
    HRESULT hr = S_OK;

    // 初始化 COM 对象
    hr = CoInitialize(NULL);
    if (FAILED(hr)) return FALSE;

    // 创建 D2D Factory（单线程工厂）
    hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory1), (void**)&amp;m_d2dFactory);
    if (FAILED(hr)) return FALSE;

    // 创建 D3D Device 和 D3D DeviceContext
    D3D_FEATURE_LEVEL featureLevels[] =
    {
        D3D_FEATURE_LEVEL_11_1,
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0,
        D3D_FEATURE_LEVEL_9_3,
        D3D_FEATURE_LEVEL_9_2,
        D3D_FEATURE_LEVEL_9_1
    };
    hr = D3D11CreateDevice(
        NULL,
        D3D_DRIVER_TYPE_HARDWARE,
        0,
        D3D11_CREATE_DEVICE_BGRA_SUPPORT,
        featureLevels,
        ARRAYSIZE(featureLevels),
        D3D11_SDK_VERSION,
        &amp;m_d3dDevice,
        NULL,
        &amp;m_d3dDeviceContext
    );
    if (FAILED(hr)) return FALSE;

    // 创建 DXGI Device
    hr = m_d3dDevice-&gt;QueryInterface(__uuidof(IDXGIDevice1), (void**)&amp;m_dxgiDevice);
    if (FAILED(hr)) return FALSE;

    // 创建 D2D Device
    hr = m_d2dFactory-&gt;CreateDevice(m_dxgiDevice, &amp;m_d2dDevice);
    if (FAILED(hr)) return FALSE;

    // 创建 D2D DeviceContext
    hr = m_d2dDevice-&gt;CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &amp;m_d2dDeviceContext);
    if (FAILED(hr)) return FALSE;

    // 创建 DXGI Factory
    IDXGIAdapter* dxgiAdapter = NULL;
    hr = m_dxgiDevice-&gt;GetAdapter(&amp;dxgiAdapter);
    if (FAILED(hr)) return FALSE;

    hr = dxgiAdapter-&gt;GetParent(IID_PPV_ARGS(&amp;m_dxgiFactory));
    if (FAILED(hr)) return FALSE;

    // 创建 DXGI SwapChain
    DXGI_SWAP_CHAIN_DESC1 swapChainDesc = { 0 };
    memset(&amp;swapChainDesc, 0, sizeof(DXGI_SWAP_CHAIN_DESC1));
    swapChainDesc.Width = 0;                           // use automatic sizing
    swapChainDesc.Height = 0;
    swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // this is the most common swapchain format
    swapChainDesc.Stereo = false;
    swapChainDesc.SampleDesc.Count = 1;                // don't use multi-sampling
    swapChainDesc.SampleDesc.Quality = 0;
    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    swapChainDesc.BufferCount = 1;                     // use double buffering to enable flip
    swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
    swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; // all apps must use this SwapEffect
    swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
    swapChainDesc.Flags = 0;

    // 设置全屏参数（没用到）
    DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullScreen = { 0 };
    memset(&amp;fullScreen, 0, sizeof(DXGI_SWAP_CHAIN_FULLSCREEN_DESC));
    fullScreen.RefreshRate.Numerator = 60;
    fullScreen.RefreshRate.Denominator = 1;
    fullScreen.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
    fullScreen.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
    fullScreen.Windowed = false;

    hr = m_dxgiFactory-&gt;CreateSwapChainForHwnd(
        m_d3dDevice,
        hwnd,
        &amp;swapChainDesc,
        nullptr,
        nullptr,
        &amp;m_dxgiSwapChain
    );
    if (FAILED(hr))
    {
        return false;
    }

    CreateRenderTarget();


    return true;
}

void ChangeSize(uint32_t width, uint32_t height)
{
    if (width == 0 || height == 0 || !m_dxgiSwapChain)
    {
        return;
    }
    HRESULT hr = S_OK;
    m_WinSize.x = width;
    m_WinSize.y = height;

    m_d2dDeviceContext-&gt;SetTarget(NULL);
    // 解除所有与 SwapChain 的绑定
    if (m_d3dDeviceContext)
    {
        m_d3dDeviceContext-&gt;ClearState();
        m_d3dDeviceContext-&gt;Flush();
    }

    m_dxgiSurface-&gt;Release();
    m_d2dTarget-&gt;Release();

    hr = m_dxgiSwapChain-&gt;ResizeBuffers(0, width, height, DXGI_FORMAT_UNKNOWN, 0);

    CreateRenderTarget();
    m_d2dDeviceContext-&gt;SetTarget(m_d2dTarget);

}

BOOL CreateRenderTarget()
{
    HRESULT hr = S_OK;

    // 创建 DXGI Surface
    hr = m_dxgiSwapChain-&gt;GetBuffer(0, IID_PPV_ARGS(&amp;m_dxgiSurface));
    if (FAILED(hr)) return false;

    // 创建 渲染目标
    D2D1_BITMAP_PROPERTIES1 d2d1_bitmap_def = {};
    d2d1_bitmap_def.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM;
    d2d1_bitmap_def.pixelFormat.alphaMode = D2D1_ALPHA_MODE_PREMULTIPLIED;
    d2d1_bitmap_def.dpiX = USER_DEFAULT_SCREEN_DPI;
    d2d1_bitmap_def.dpiY = USER_DEFAULT_SCREEN_DPI;
    d2d1_bitmap_def.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
    d2d1_bitmap_def.colorContext = NULL;
    hr = m_d2dDeviceContext-&gt;CreateBitmapFromDxgiSurface(m_dxgiSurface, d2d1_bitmap_def, &amp;m_d2dTarget);
    if (FAILED(hr)) return false;
}

LRESULT WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_CLOSE:
    {
        PostQuitMessage(0);
        break;
    }
    case WM_SIZE:
    {
        ChangeSize(LOWORD(lParam), HIWORD(lParam));
        break;
    }
    case WM_KEYDOWN:
    {
        break;
    }
    case WM_KEYUP:
    {
        break;
    }
    case WM_LBUTTONDOWN:
    {
        Full = !Full;
        m_dxgiSwapChain-&gt;SetFullscreenState(Full, NULL);
        break;
    }
    case WM_LBUTTONUP:
    {
        break;
    }
    case WM_MOUSEMOVE:
    {
        m_MousePos.x = LOWORD(lParam);
        m_MousePos.y = HIWORD(lParam);

        break;
    }
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
</code></pre>
<p>这个最小Demo可以正常全屏，然后我怀疑是我GameEngine项目用到了多线程的问题，当然，由于多线程也导致我在渲染线程中操作交换链时需要格外小心，于是经过考虑，我把GameEngine改成了单线程的，单线程有一个问题我一直接受不了就是拖拽窗口大小时画面会卡住，所以我才想用多线程渲染和消息循环两个线程来解决这个问题，但问题好像没有出在这里。</p>
<p>经过一段时间DEBUG，我发现是因为我在<code>ShowWindow</code>函数之前调用了<code>SetFullscreenState</code>导致的，应该先<code>ShowWindow</code>在<code>SetFullscreenState</code>，于是该问题解决，那么我是不是可以改回双线程渲染了呢？</p>
<p>确实可以，我重新改回了双线程渲染并封装了一个设置渲染目标回到交换链的函数，里面用到了Direct2d工厂的锁来确保线程安全，测试也没有任何问题</p>
<p>不！测试有问题，全屏模式下输入中文会卡死，我在微软找到一段描述</p>
<p><img alt="" src="../QQ%E5%9B%BE%E7%89%8720230102213654.jpg" /></p>
<p>经过一些调试，我发现确实是发生了死锁，在下面这行代码中</p>
<p><img alt="QQ图片20230102215353" src="../QQ%E5%9B%BE%E7%89%8720230102215353.png" /></p>
<p>该死锁发生在消息循环线程中，这说明这个锁在其它地方被执行并没有释放，这好像和微软说的又不太一样</p>
<p>既然是在消息循环中死锁了，那就只能是在渲染线程中没有释放，为什么呢？</p>

              
            </article>
            
          </div>
        </div>
        
          <a href="#" class="md-top md-icon" data-md-component="top" hidden>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12Z"/></svg>
            回到页面顶部
          </a>
        
      </main>
      
        <footer class="md-footer">
  
    
    <nav class="md-footer__inner md-grid" aria-label="页脚" >
      
        
        <a href="../../2022-7-7-9-40/Direct2dInit/" class="md-footer__link md-footer__link--prev" aria-label="上一页: Direct2d 初始化" rel="prev">
          <div class="md-footer__button md-icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
          </div>
          <div class="md-footer__title">
            <div class="md-ellipsis">
              <span class="md-footer__direction">
                上一页
              </span>
              Direct2d 初始化
            </div>
          </div>
        </a>
      
      
        
        <a href="../../../QT/2022-7-26-10-00/QT%E7%BC%96%E8%AF%91%E6%8A%A5%E9%94%99/" class="md-footer__link md-footer__link--next" aria-label="下一页: QT因库版本不一致导致的报错" rel="next">
          <div class="md-footer__title">
            <div class="md-ellipsis">
              <span class="md-footer__direction">
                下一页
              </span>
              QT因库版本不一致导致的报错
            </div>
          </div>
          <div class="md-footer__button md-icon">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
          </div>
        </a>
      
    </nav>
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
    <div class="md-copyright__highlight">
      Copyright &copy; 2022
    </div>
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
        <div class="md-social">
  
    
    
    <a href="https://github.com/songshu007" target="_blank" rel="noopener" title="GitHub | songshu007" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
    </a>
  
    
    
    <a href="https://space.bilibili.com/286704129" target="_blank" rel="noopener" title="BiliBili | 晒太阳的松鼠" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M488.6 104.1c16.7 18.1 24.4 39.7 23.3 65.7v202.4c-.4 26.4-9.2 48.1-26.5 65.1-17.2 17-39.1 25.9-65.5 26.7H92.02c-26.45-.8-48.21-9.8-65.28-27.2C9.682 419.4.767 396.5 0 368.2V169.8c.767-26 9.682-47.6 26.74-65.7C43.81 87.75 65.57 78.77 92.02 78h29.38L96.05 52.19c-5.75-5.73-8.63-13-8.63-21.79 0-8.8 2.88-16.06 8.63-21.797C101.8 2.868 109.1 0 117.9 0s16.1 2.868 21.9 8.603L213.1 78h88l74.5-69.397C381.7 2.868 389.2 0 398 0c8.8 0 16.1 2.868 21.9 8.603 5.7 5.737 8.6 12.997 8.6 21.797 0 8.79-2.9 16.06-8.6 21.79L394.6 78h29.3c26.4.77 48 9.75 64.7 26.1zm-38.8 69.7c-.4-9.6-3.7-17.4-10.7-23.5-5.2-6.1-14-9.4-22.7-9.8H96.05c-9.59.4-17.45 3.7-23.58 9.8-6.14 6.1-9.4 13.9-9.78 23.5v194.4c0 9.2 3.26 17 9.78 23.5s14.38 9.8 23.58 9.8H416.4c9.2 0 17-3.3 23.3-9.8 6.3-6.5 9.7-14.3 10.1-23.5V173.8zm-264.3 42.7c6.3 6.3 9.7 14.1 10.1 23.2V273c-.4 9.2-3.7 16.9-9.8 23.2-6.2 6.3-14 9.5-23.6 9.5-9.6 0-17.5-3.2-23.6-9.5-6.1-6.3-9.4-14-9.8-23.2v-33.3c.4-9.1 3.8-16.9 10.1-23.2 6.3-6.3 13.2-9.6 23.3-10 9.2.4 17 3.7 23.3 10zm191.5 0c6.3 6.3 9.7 14.1 10.1 23.2V273c-.4 9.2-3.7 16.9-9.8 23.2-6.1 6.3-14 9.5-23.6 9.5-9.6 0-17.4-3.2-23.6-9.5-7-6.3-9.4-14-9.7-23.2v-33.3c.3-9.1 3.7-16.9 10-23.2 6.3-6.3 14.1-9.6 23.3-10 9.2.4 17 3.7 23.3 10z"/></svg>
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    <script id="__config" type="application/json">{"base": "../../../..", "features": ["navigation.tabs", "navigation.top", "navigation.indexes", "navigation.expand", "search.suggest", "search.highlight"], "search": "../../../../assets/javascripts/workers/search.b97dbffb.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.config.lang": "ja", "search.config.pipeline": "trimmer, stemmer", "search.config.separator": "[\\s\\-\uff0c\u3002]+", "search.placeholder": "\u641c\u7d22", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version.title": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
    
    
      <script src="../../../../assets/javascripts/bundle.6c7ad80a.min.js"></script>
      
    
  </body>
</html>